//
//  WeChatShareWebService.m
//  YYZB
//
//  Created by 顾悦 on 16/4/19.
//
//

#import "WeChatShareWebService.h"

@implementation WeChatShareWebService

- (void)fetchParametersByType:(NSString *)type
                          way:(NSString *)way
            completionHanlder:(void (^)(NSArray *items, NSError *error))completionHanlder {
    NSString *URL = @"ShareWeChat/GetWeChatShareParam";
    NSDictionary *params = @{
                             @"ShareType": type,
                             @"ShareWay": way
                             };
    NSString *URLString = [self formattedURLString:params method:URL sessionNeeded:YES];
    [self sendHTTPGetRequest:URLString completionHandler:^(id result, NSError *error) {
        if (error != nil) {
            completionHanlder(nil, error);
        } else {
            NSError *err;
            NSArray *items = [self unboxedValue:result error:&err];
            completionHanlder(items, err);
        }
    }];
}

- (void)uploadShareResultByID:(NSString *)ID
                         type:(NSString *)type
                       userId:(NSString *)userId
                       result:(BOOL)result
            completionHanlder:(void (^)(NSArray *items, NSError *error))completionHanlder  {
    NSString *URL = @"ShareWeChat/AddWeChatShareResult";
    NSDictionary *params = @{
                             @"WeChatShareId": ID,
                             @"UserType": type,
                             @"UserId": userId,
                             @"ShareResult": @(result)
                             };
    NSString *URLString = [self formattedURLString:params method:URL sessionNeeded:YES];
    [self sendHTTPGetRequest:URLString completionHandler:^(id result, NSError *error) {
        if (error != nil) {
            completionHanlder(nil, error);
        } else {
            NSError *err;
            NSArray *items = [self unboxedValue:result error:&err];
            completionHanlder(items, err);
        }
    }];
}

@end
